const user_key = 'zh-user'
const user = {
  namespaced: true,
  state: () => {
    // 用户信息
    return {
      userInfo: {
        token: '',
        userId: null
      }
    }
  },

  mutations: {
    setToken: (state, value) => {
      // console.log(value);
      state.userInfo = value
      uni.setStorageSync(user_key, value.token)
    },
    delToken(state) {
      state.userInfo = {
        token: '',
        userId: null
      }
      uni.removeStorageSync(user_key)
    }
  }
}

export default user